import 'package:word_game/engine/core.dart';
import 'equipment.dart';

class EquipmentView extends Sightable {
  List<Map<EquipmentPart, Equipment>> equipments = [];
  EquipmentView() : super('装备');

  void equip(Equipment equipment) {
    for (var map in equipments) {
      if (map.keys.first == equipment.belongingPart) {
        map[equipment.belongingPart] = equipment;
        Engine.instance.displayer.displayString('成功装备[${equipment.name}]。');
      }
    }
  }

  @override
  List<CommandItem> optionCommands() {
    return equipments.map((f)=> f.values.first).toList();
  }
  
  @override
  String optionCommandsDesc() {
    String desc = '';
    for (var map in equipments) {
      int index = equipments.indexOf(map);
      String partName = EquipmentPartHelper.descForEnum(map.keys.first);
      desc += '[${index+1}]${partName}:${map.values.first?.name??'-'} ';
    }
    return desc;
  }
}